/**
 * 学习目标：props校验
 */
import React from 'react';

// 1. 导入类型校验包prop-types
import PropTypes from 'prop-types';

export default class App extends React.Component {
  render() {
    return (
      <div>
        <Child msg={81} list={[]} person={{ name: 'zs', age: 18 }} />
      </div>
    );
  }
}

class Child extends React.Component {
  render() {
    return <div>Child</div>;
  }
}

// 2. 给组件设置规则对象
Child.propTypes = {
  // 3. 给props属性设置类型
  msg: PropTypes.number,
  list: PropTypes.array,
  // JSX类型
  // title: PropTypes.element.isRequired,
  person: PropTypes.shape({
    name: PropTypes.string,
    age: PropTypes.number,
  }),
};
